<?php
/**
 * Prado Portal.
 *
 * @author Steen Rabol <steen.rabol@gmail.com>
 * @link http://www.pradoportal.dk/
 * @copyright Copyright &copy; 2006,2007,2008 Steen Rabol
 * @license http://www.pradoportal.dk
 * @version $Id: NewsPortlet.php 289 2008-11-14 05:34:40Z steen.rabol@gmail.com $
 * @package Pradoportal.Porttlets.NewsPortlet.Admin
 *
 */

Prado::using('Application.Portlets.Portlet');
class NewsPortlet extends Portlet
{
	private $_newsconfig	= null;

	public function getNewsConfig()
	{
		if($this->_newsconfig === null)
		{
			$crow = $this->DataAccess->createCommand("select * from tblconfig where name='News_" . $this->Parameters['id'] . "'")->queryRow();

			if($crow)
			{
				$this->NewsConfig = explode(";",$crow['value']);
			}
			else
			{
				$this->Newsconfig	= array("showheaders" => 1, "showcount" => 5);
			}
		}
		return $this->_newsconfig;
	}

	public function setNewsConfig($value)
	{
		$this->_newsconfig	= $value;
	}

	public function onLoad($param)
	{
		parent::onLoad($param);
		$this->NewsDataList->DataSource	= $this->DataAccess->createCommand("select * from tblnews where contentid='" . $this->Parameters['id'] . "' && expire > " . time())->query();
		$this->NewsDataList->dataBind();
	}

}
?>